using System;

namespace RegexEditor
{
	/// <summary>
	/// Provides generic extension methods.
	/// </summary>
	public static class StringExtensions
	{
		#region Public Members

		/// <summary>
		/// Truncates a string.
		/// </summary>
		/// <param name="value">The string value.</param>
		/// <param name="length">The maximum length.</param>
		/// <returns>The truncated string.</returns>
		public static string Truncate(this string value, int length)
		{
			if (value.Length > length)
				return value.Substring(0, length) + "...";

			return value;
		}

		#endregion
	}
}
